const Router = require('@koa/router'); // 添加: 引入路由模块
const router = new Router({ prefix: '/api/scenic' }); // 修改: 创建路由实例，并设置前缀

const attractionsController = require('../controllers/attractionsController');

// 获取景点列表
// 生成swagger注释
/**
 * @swagger
 * /api/scenic/list:
 *   get:
 *     summary: 获取景点列表
 *     responses:
 *       200:
 *         description: 景点列表
 */
router.get('/list', attractionsController.getAttractionsList);

// 获取景点详情
// 生成swagger注释
/**
 * @swagger
 * /api/scenic/{id}:
 *   get:
 *     summary: 获取景点详情
 *     parameters:
 *       - in: path
 *         name: id
 *         required: true
 *         schema:
 *           type: string
 *         description: 景点ID
 *     responses:
 *       200:
 *         description: 景点详情
 */
router.get('/:id', attractionsController.getAttractionById);

// 添加新景点
// 生成swagger注释
/**
 * @swagger
 * /api/scenic/add:
 *   post:
 *     summary: 添加新景点
 *     requestBody:
 *       required: true
 *       content:
 *         application/json:
 *           schema:
 *             type: object
 *             properties:
 *               name:
 *                 type: string
 *               description:
 *                 type: string
 *     responses:
 *       201:
 *         description: 景点添加成功
 */
router.post('/add', attractionsController.addAttraction);

// 更新景点信息
// 生成swagger注释
/**
 * @swagger
 * /api/scenic/update/{id}:
 *   put:
 *     summary: 更新景点信息
 *     parameters:
 *       - in: path
 *         name: id
 *         required: true
 *         schema:
 *           type: string
 *         description: 景点ID
 *     requestBody:
 *       required: true
 *       content:
 *         application/json:
 *           schema:
 *             type: object
 *             properties:
 *               name:
 *                 type: string
 *               description:
 *                 type: string
 *     responses:
 *       200:
 *         description: 景点更新成功
 */
router.put('/update/:id', attractionsController.updateAttraction);

// 删除景点
// 生成swagger注释
/**
 * @swagger
 * /api/scenic/delete/{id}:
 *   delete:
 *     summary: 删除景点
 *     parameters:
 *       - in: path
 *         name: id
 *         required: true
 *         schema:
 *           type: string
 *         description: 景点ID
 *     responses:
 *       200:
 *         description: 景点删除成功
 */
router.delete('/delete/:id', attractionsController.deleteAttraction);

// 添加评论
// 生成swagger注释
/**
 * @swagger
 * /api/scenic/comment/{id}:
 *   post:
 *     summary: 添加评论
 *     parameters:
 *       - in: path
 *         name: id
 *         required: true
 *         schema:
 *           type: string
 *         description: 景点ID
 *     requestBody:
 *       required: true
 *       content:
 *         application/json:
 *           schema:
 *             type: object
 *             properties:
 *               comment:
 *                 type: string
 *     responses:
 *       201:
 *         description: 评论添加成功
 */
router.post('/comment/:id', attractionsController.addComment);

// 获取景点评论
// 生成swagger注释
/**
 * @swagger
 * /api/scenic/comments/{id}:
 *   get:
 *     summary: 获取景点评论
 *     parameters:
 *       - in: path
 *         name: id
 *         required: true
 *         schema:
 *           type: string
 *         description: 景点ID
 *     responses:
 *       200:
 *         description: 景点评论列表
 */
router.get('/comments/:id', attractionsController.getComments);

module.exports = router; // 导出路由实例